<script>
export default {
  data() {
    return {
      bg: 'rgba(255, 255, 255, 0.9)',
    }
  },
  methods: {
    changeBg() {
      this.bg = 'rgba(0, 255, 255, 0.3)'
    },
  },
}
</script>

<template>
  <div class="wrap" :style="{ '--bg': bg }">
    <div class="title" @click="changeBg">测试</div>
    <br />
    <br />

    <div class="data-link-wrap">
      <div class="data-link" :style="{ background: bg }">右侧不动</div>
    </div>
    <van-tabs swipeable sticky :offset-top="70" :background="bg">
      <van-tab title="标签 1">
        <div v-for="n in 100" :key="n">内容 1</div>
      </van-tab>
      <van-tab title="标签 2">内容 2</van-tab>
      <van-tab title="标签 3">内容 3</van-tab>
      <van-tab title="标签 4">内容 4</van-tab>
      <van-tab title="标签 5">内容 5</van-tab>
      <van-tab title="标签 6">内容 6</van-tab>
    </van-tabs>
  </div>
</template>

<style scoped>
.wrap {
  background-color: #f2f2f2;
  overflow-y: auto;
  height: calc(100vh - 70px);
}

.title {
  background-color: var(--bg);
}

.data-link-wrap {
  position: sticky;
  top: 0;
  z-index: 99999;

  .data-link {
    position: absolute;
    right: 0;
    top: 0;
    height: 44px;
    line-height: 44px;
    padding: 0 10px;
    background-color: #fff;
  }
}

::v-deep .van-sticky {
  margin-right: 70px;

  &.van-sticky--fixed {
    margin: 0 20px;
  }
}
</style>
